package mall

import (
	"errors"
	"newbeemallStudyProject/global"
	"newbeemallStudyProject/model/mall/response"
	"newbeemallStudyProject/model/manage"
)

type MallCarouselService struct{}

func (m *MallCarouselService) GetCarous(num int) (error error, list interface{}) {

	var mallCarousList []response.MallCarouselResponse
	var manCar []manage.MallCarousel
	error = global.GVA_DB.Where("is_deleted = 0").Order("carousel_rank desc").Limit(num).Find(&manCar).Error
	if error != nil {
		return errors.New("查询失败"), nil
	}
	for _, l := range manCar {
		carouselResponse := response.MallCarouselResponse{
			CarouselUrl: l.CarouselUrl,
			RedirectUrl: l.RedirectUrl,
		}
		mallCarousList = append(mallCarousList, carouselResponse)
	}
	return error, mallCarousList
}
